package com.ruitu.health_2.ui.adapter;

import android.content.Context;
import android.widget.TextView;

import com.makeramen.roundedimageview.RoundedImageView;
import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.health_2.R;
import com.ruitu.router_module.bean.product.ProHome;
import com.ruitu.router_module.util.GlideUtil;

public class HorizonProListAdapter extends ListBaseAdapter<ProHome> {
    public HorizonProListAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_pro_horizon_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        RoundedImageView icon = holder.getView(R.id.icon);// 图片
        TextView tv_name = holder.getView(R.id.tv_name);// 名称
        TextView tv_price = holder.getView(R.id.tv_price);// 价格
        TextView tv_integral = holder.getView(R.id.tv_integral);// 积分

//        int itemWidth = SizeUtils.dp2px(70);
//        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) icon.getLayoutParams();
//        params.width = itemWidth;
//        params.height = itemWidth;
//        icon.setLayoutParams(params);

        ProHome pro = mDataList.get(position);
        tv_name.setText(pro.getName());
        tv_price.setText("￥" + pro.getPrice());
        GlideUtil.loadImg(pro.getPic(), icon);

        try {
            if (Integer.parseInt(pro.getGiftPoint()) > 0) {
//                tv_integral.setText("送" + pro.getGiftPoint() + "积分");
                tv_integral.setText("");
            } else {
                tv_integral.setText("");
            }
        } catch (Exception e) {
            e.printStackTrace();
            tv_integral.setText("");
        }
    }
}
